const TOEKN_KEY = "token"
const ROLES_KEY = "roles"
const NAME_KEY = "username"
// token
export const getToken = function () {
    return localStorage.getItem(TOEKN_KEY)
}
export const setToken = function (token: string) {
    localStorage.setItem(TOEKN_KEY, token)
}
export const removeToken = function () {
    localStorage.removeItem(TOEKN_KEY)
}
// roles
export const setRoles = function (roles: string) {
    localStorage.setItem(ROLES_KEY, JSON.stringify(roles))
}
export const getRoles = function (): string[] {
    return JSON.parse(localStorage.getItem(ROLES_KEY) || '[]')
}
export const removeRoles = function () {
    localStorage.removeItem(ROLES_KEY)
}
// username
export const setUserName = function (name: string) {
    return localStorage.setItem(NAME_KEY, name)
}
export const getUserName = function (): string {
    return localStorage.getItem(NAME_KEY) || ''
}